package smb.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.jdbc.core.RowMapper;
import smb.domain.Score;

import java.sql.ResultSet;
import java.sql.SQLException;

@Data
@AllArgsConstructor
public class SectionScore {
    private SectionVo section;
    private CourseVo course;
    private ScoreVo score;

    public static class rowMapper implements RowMapper<SectionScore> {
        @Override
        public SectionScore mapRow(ResultSet resultSet, int i) throws SQLException {
            SectionVo sectionVo = new SectionVo(resultSet.getString(1), resultSet.getInt(2), resultSet.getString(3));
            CourseVo courseVo = new CourseVo(resultSet.getString(4), resultSet.getString(5));
            ScoreVo scoreVo = new ScoreVo(resultSet.getDouble(6), resultSet.getDouble(7), resultSet.getDouble(8), resultSet.getDouble(9), resultSet.getDouble(10), resultSet.getTimestamp(11));
            return new SectionScore(sectionVo, courseVo, scoreVo);
        }
    }
}
